package 函数式编程

object ParameterInfer {
  def main(args: Array[String]): Unit = {
    val list = List(1, 2, 3, 4)
    println(list.map((x: Int) => x + 1))
    println(list.map((x) => x + 1))
    println(list.map(x => x + 1))
    println(list.map(_ + 1))


    //    val i = list.reduce(f1)
    //    list.reduce((x: Int, y: Int) => x + y)
    //    list.reduce((x, y) => x + y)
    //    //各变量在=>在👉只出现了1次,可以使用_简化
    //    list.reduce(_ + _)


    def f1(x: Int, y: Int): Int = {
      x + y
    }

  }
}
